package org.shj.pattern.observer;

import java.util.ArrayList;
import java.util.List;

public abstract class Subject {
	
	private List<Observer> observers = new ArrayList<Observer>();
	
	public void attach(Observer ob){
		this.observers.add(ob);
	}
	
	public void detach(Observer ob){
		observers.remove(ob);
	}
	
	public void notifyObservers(){
		for(Observer ob : observers){
			ob.update();
		}
	}
	
	public abstract String getSubjectState();
	
	public abstract void setSubjectState(String subjectState);
}
